﻿using System;

namespace Dexter.Domain.Model {
	public partial class LegacyUrl {
		public virtual void ValidateForSave() {
			if (this.Id != 0)
				throw new ArgumentOutOfRangeException("Id", "Invalid legacy url key");

			BasicValidate();
		}

		public virtual void ValidateForUpdate() {
			if (this.Id < 1)
				throw new ArgumentOutOfRangeException("Id", "Invalid legacy url key");

			BasicValidate();
		}

		public virtual void ValidateForDelete() {
			if (this.Id < 1)
				throw new ArgumentOutOfRangeException("Id", "Invalid legacy url key");
		}

		void BasicValidate() {
			if (string.IsNullOrEmpty(this.SourceUrl))
				throw new ArgumentException("SourceUrl", "Invalid SourceUrl");

			if (this.SourceUrl == null)
				throw new ArgumentNullException("SourceUrl", "Invalid SourceUrl");

			if (this.TargetUrl == null)
				throw new ArgumentNullException("TargetUrl", "Invalid SourceUrl");
		}
	}
}